-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolving task no.4 with ugly code #22
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking overall. The real issue here is naming.
app.js
Outdated
return convertToHours(getFullTimeOfSleep); | ||
} | ||
} | ||
const getMiliseconds = (h,m) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide default values, e.g. 0
app.js
Outdated
const convertedClockStop = clockStop.split(":"); | ||
const msMotive = convertToMs(convertedMotive[0],convertedMotive[1]); | ||
const msClockStop = convertToMs(convertedClockStop[0],convertedClockStop[1]); | ||
const maxNum = Math.max(...[msMotive,msClockStop]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why create an array and use spread? Math.max(msMotive, msClockStop) would suffice.
app.js
Outdated
@@ -0,0 +1,34 @@ | |||
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea with taking output formatter as a function parameter. I'd give it a more meaningful name, though. convertToHours
would be named outputFormatter
, for example.
const msClockStop = convertToMs(convertedClockStop[0],convertedClockStop[1]); | ||
const maxNum = Math.max(...[msMotive,msClockStop]); | ||
const minNum = Math.min(...[msClockStop,msMotive]); | ||
if(maxNum && minNum > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this condition is evaluated as false? What would be returned then?
@@ -0,0 +1,34 @@ | |||
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => { | |||
const convertedMotive = motiveTime.split(":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable names don't say much. If I didn't see the values, I wouldn't know what is stored and assigned to them.
app.js
Outdated
return ((h*60*60+m*60)*1000); | ||
} | ||
|
||
function timeConversion(millisec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There would be a better name, e.g. formatTimeToString
.
app.js
Outdated
@@ -0,0 +1,34 @@ | |||
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function shouldn't have 4 params
No description provided.